"""
输入的表达式没有括号
"""

class Solution:
    def calculate(self, s: str) -> int:
        res = []
        num = 0
        pre_sign = '+'
        for c in s+'+':

            if c.isdigit():
                num = int(c) + num * 10
            elif c != " ":
                if pre_sign == '+':
                    res.append(num)
                elif pre_sign == '-':
                    res.append(-num)
                elif pre_sign == '*':
                    res.append(num * res.pop())
                else:
                    print(res, num)
                    res.append(int(res.pop() / num))
                    print(res, num)

                pre_sign = c
                num = 0
        
        return sum(res)